<template>
    <div>
        <el-card>
            <div id="main" style="width: 600px;height:400px;"></div>
        </el-card>      
    </div>
</template>

<script>
  import echarts from 'echarts'
  import {getEcharts} from 'network/reports'
  import _ from 'lodash'

  export default {
     name:'Reports',
     data(){
         return{
             options: {
                title: {
                text: '用户来源'
                },
                tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                    backgroundColor: '#E9EEF3'
                    }
                }
                },
                grid: {
                  left: '3%',
                  right: '4%',
                  bottom: '3%',
                 containLabel: true
                },
                xAxis: [
                {
                    boundaryGap: false
                }
                ],
                yAxis: [
                {
                    type: 'value'
                }
                ]
            }
         }
     },
     mounted(){
       var myChart = echarts.init(document.getElementById('main'));
       getEcharts().then(res=>{
          if(res.data.meta.status!==200){
             return this.$message.error('数据获取失败');
          } 
          const result = _.merge(res.data.data,this.options);
          myChart.setOption(result);
          console.log(res);
       },err=>{

       });
             
     
   }
  }
</script>

<style lang="less" scoped>

</style>